Scala type system: basic type mismatch

I have a problem with the type mismatch of the base type: I have a class with a method

def Create(nodeItem : NodeItem) = {p_nodeStart.addEndNode(nodeItem)}

where p_nodeStart is NodeCache

class NodeCache[END_T<:BaseNode] private(node: Node) extends BaseNode {
def addEndNode(endNode : END_T) = {this.CACHE_HAS_ENDNODES.Create(endNode)}

and the error he gives me:

error: type mismatch;
found   : nodes.NodeItem
required: Nothing
    def Create(nodeItem : NodeItem) = {p_nodeStart.addEndNode(nodeItem)}

while NodeCache is defined as

object NodeTrigger {
def Create() {
val nodeTimeCache         = NodeCache.Create[NodeItem](node)

and in the NodeCache object

object NodeCache {
def Create[END_T<:BaseNode]() {
val nodeCache = new NodeCache[END_T](node);

Any ideas how to fix the error?

+3
source share
1 answer

where p_nodeStart is NodeCache

NodeCache - what? NodeCache is parameterized, and it looks like p_nodeStart is NodeCache [Nothing]. How was this determined?

+1
source

Source: https://habr.com/ru/post/1740399/


All Articles