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
The compiler inserts a stabilizer (scala/scala#5999) because the signature of f.m refers to Foo.this.I:
<synthetic> <stable> <artifact> val stabilizer$1: Foo{type FT = T} = Test.this.f[T];
stabilizer$1.m(b, None)
The T in the stabilizer's type is a reference to the type param of f. The type error is
A.scala:11: error: type mismatch;
found : Any
required: T
f.m(b, None)
^
The variant (in comments) using a type parameter FT instead of a type member compiles correctly.
The difference is how the parameter type FT is represented in the method stabilizer$1.m (after asSeenFrom):
when FT is a type param, stabilizer$1.m has parameter type TypeRef to T, the undetermined type param of f. FT is substituted.
when FT is a type member, m's parameter type is an AliasNoArgsTypeRef with prefix stabilizer$1.type and symbol FT (it's not substitued). It's relativeInfo indeed points to T, the undetermined type param of f.
Now the issue is that instantiateTypeParams and inferMethodInstance use substSym to replace references to the type param T, but that leaves the AliasNoArgsTypeRef(stabilizer$1.type, FT) untouched.
I think this is specific to stabilizers, because the compiler inserts a stable val but leaves some type params of its rhs undetermined. That's not possible to write in source, val stabilizer$1: Foo{type FT = T} would need a concrete type for T.
So maybe there's some workaround we can do when creating the stabilizer. Changing methods like substSym / instantiateTypeParams / inferMethodInstance for AliasTypeRefs would likely break things (normalize gives the relativeInfo, but that probably drops too much information if we call it that widely).
The text was updated successfully, but these errors were encountered:
This fails to compile on 2.13:
The compiler inserts a stabilizer (scala/scala#5999) because the signature of
f.m
refers toFoo.this.I
:The
T
in the stabilizer's type is a reference to the type param off
. The type error isThe variant (in comments) using a type parameter
FT
instead of a type member compiles correctly.The difference is how the parameter type
FT
is represented in the methodstabilizer$1.m
(after asSeenFrom):FT
is a type param,stabilizer$1.m
has parameter typeTypeRef
toT
, the undetermined type param off
.FT
is substituted.FT
is a type member,m
's parameter type is anAliasNoArgsTypeRef
with prefixstabilizer$1.type
and symbolFT
(it's not substitued). It'srelativeInfo
indeed points toT
, the undetermined type param off
.Now the issue is that
instantiateTypeParams
andinferMethodInstance
use substSym to replace references to the type paramT
, but that leaves theAliasNoArgsTypeRef(stabilizer$1.type, FT)
untouched.I think this is specific to stabilizers, because the compiler inserts a stable
val
but leaves some type params of its rhs undetermined. That's not possible to write in source,val stabilizer$1: Foo{type FT = T}
would need a concrete type forT
.So maybe there's some workaround we can do when creating the stabilizer. Changing methods like substSym / instantiateTypeParams / inferMethodInstance for AliasTypeRefs would likely break things (
normalize
gives therelativeInfo
, but that probably drops too much information if we call it that widely).The text was updated successfully, but these errors were encountered: