You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
trait ObjectMixIn {
class Klass()
}
object ConcreteObject extends ObjectMixIn
class App {
lazy val klass: ConcreteObject.Klass = wire[ConcreteObject.Klass]
}
Fails compilation with
Error:(10, 46) type mismatch;
found : ObjectMixIn.this.Klass
required: ConcreteObject.Klass
lazy val klass: ConcreteObject.Klass = wire[ConcreteObject.Klass]
The macro is returning the (abstract) ObjectMixIn.this.Klasss type rather than the concrete ConcreteObject.Klass
And
trait ObjectMixIn {
class Depedency
class Klass(depedency: Depedency)
}
object ConcreteObject extends ObjectMixIn
class App {
lazy val depedency: ConcreteObject.Depedency = new ConcreteObject.Depedency
lazy val klass = wire[ConcreteObject.Klass]
}
Fails compilation with
Error:(12, 24) Cannot find a value of type: [ObjectMixIn.this.Depedency]
lazy val klass = wire[ConcreteObject.Klass]
So, in this case, it appears that wire is looking for as ObjectMixIn.this.Depedency rather than ConcreteObject.Dependency (and thus isn't finding it)
Described in the general case, it appears that wire[ConcreteObjectExtendsTrait.ClassDefinedInTrait] is being treated as wire[Trait.ClassDefinedInTrait]
My current workaround is to use wireWith, which seems to pull in the full, concrete-type correctly
trait ObjectMixIn {
class Klass()
object Klass {
def apply() = new Klass()
}
}
object ConcreteObject extends ObjectMixIn
class App {
lazy val klass: ConcreteObject.Klass = wireWith(ConcreteObject.Klass.apply _)
}
Thankfully, this works without adding too much boilerplate
The text was updated successfully, but these errors were encountered:
richard-shurtz
changed the title
Incorrect type when wiring an inner class of an object
Incorrect type returned from wire when wiring an inner class of an trait implemented by an object
Mar 2, 2021
richard-shurtz
changed the title
Incorrect type returned from wire when wiring an inner class of an trait implemented by an object
When wireing an inner class of an trait implemented by an object, wire is treating it as the trait's abstract type rather than the object's concrete type
Mar 5, 2021
richard-shurtz
changed the title
When wireing an inner class of an trait implemented by an object, wire is treating it as the trait's abstract type rather than the object's concrete typewire[ConcreteObjectExtendsTrait.ClassDefinedInTrait] is being treated as wire[Trait.ClassDefinedInTrait]Mar 5, 2021
Fails compilation with
The macro is returning the (abstract)
ObjectMixIn.this.Klass
s type rather than the concreteConcreteObject.Klass
And
Fails compilation with
So, in this case, it appears that
wire
is looking for asObjectMixIn.this.Depedency
rather thanConcreteObject.Dependency
(and thus isn't finding it)Described in the general case, it appears that
wire[ConcreteObjectExtendsTrait.ClassDefinedInTrait]
is being treated aswire[Trait.ClassDefinedInTrait]
My current workaround is to use
wireWith
, which seems to pull in the full, concrete-type correctlyThankfully, this works without adding too much boilerplate
The text was updated successfully, but these errors were encountered: