Description
The following still fails:
class dummy(b: Boolean) extends annotation.StaticAnnotation object Test: def foo(elem: Int, bla: Int @dummy(elem == 0)) = bla-- Error: try/annn2.scala:9:37 ------------------------------------------------- 9 | def foo(elem: Int, bla: Int @dummy(elem == 0)) = bla | ^^^^^^^^^ | undefined: elem.== # -1: TermRef(TermParamRef(elem),==) at typerThe initial typing of the arguments work, but when we want to create the MethodType using
fromSymbols
we perform a substitution. We correctly substituteTermRef(NoPrefix, elem)
by aTermParamRef
representing the first parameter of the MethodType, the TypeMap goes back up one level, and creates newelem.==
which can be done without forcing the underlying type ofelem
, but when we go back up one more level and create a newelem.==(0)
, the TypeAssigner for Apply forces the computation of the underlying type ofelem.==
, which in turn requires computing the underlying type ofelem
, where we getNoType
because we're in the middle of computingparamInfos
:scala3/compiler/src/dotty/tools/dotc/core/Types.scala
Lines 4697 to 4700 in d490d13
To avoid this issue it seems we'd need
paramInfos
to be filled progressively as we compute each parameter, so the second parameter can at least safely refer to the first one.
Originally posted by @smarter in #19957 (comment)