Scala parameter type return type

In the following code using 2.10.0M3 in the Eclipse 2.1.0 plugin for 2.10M3. I am using the default setting designed for JVM 1.5

class GeomBase[T <: DTypes] { abstract class NewObjs { def newHex(gridR: GridBase, coodI: Cood): gridR.HexRT } class GridBase { selfGrid => type HexRT = HexG with T#HexTr def uniformRect (init: NewObjs) { val hexCood = Cood(2 ,2) val hex: HexRT = init.newHex(selfGrid, hexCood)// won't compile } } } 

Error message:

 Description Resource Path Location Type type mismatch; found: GeomBase.this.GridBase#HexG with T#HexTr required: GridBase.this.HexRT (which expands to) GridBase.this.HexG with T#HexTr GeomBase.scala 

Why does the compiler believe that the method returns a project of the type GridBase # HexG when it should be this particular instance of GridBase?

Change is transferred to a simpler code class in response to comments, now another error message appears.

 package rStrat class TestClass { abstract class NewObjs { def newHex(gridR: GridBase): gridR.HexG } class GridBase { selfGrid => def uniformRect (init: NewObjs) { val hex: HexG = init.newHex(this) //error here } class HexG { val test12 = 5 } } } 

.

 Error line 11:Description Resource Path Location Type type mismatch; found : gridR.HexG required: GridBase.this.HexG possible cause: missing arguments for method or constructor TestClass.scala /SStrat/src/rStrat line 11 Scala Problem 

Update. I switched to 2.10.0M4 and updated the plugin to the M4 version in the new version of Eclipse and switched to JVM 1.6 (and 1.7), but the problems did not change.

+6
source share
2 answers

registered as SI-5958 - replace this in the dependent method type

+4
source

Now it works with 2.10.0M7. Bug fixed.

 val hex: HexRT = init.newHex(selfGrid, hexCood) //now compiles and runs correctly 
+2
source

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


All Articles