File tree 2 files changed +14
-1
lines changed
compiler/src/dotty/tools/dotc 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -140,8 +140,11 @@ class CyclicReference private (val denot: SymDenotation)(using Context) extends
140
140
// cycleSym.flags would try completing denot and would fail, but here we can use flagsUNSAFE to detect flags
141
141
// set by the parser.
142
142
val unsafeFlags = cycleSym.flagsUNSAFE
143
- val isMethod = unsafeFlags.is(Method )
143
+ val isMethod = unsafeFlags.is(Method ) // sometimes,isMethod and isConstructor can both be true!
144
144
val isVal = ! isMethod && cycleSym.isTerm
145
+ val isConstructor = cycleSym.isConstructor
146
+
147
+ // println("isMethod?"+isMethod+",isConstr:"+isConstructor)
145
148
146
149
/* This CyclicReference might have arisen from asking for `m`'s type while trying to infer it.
147
150
* To try to diagnose this, walk the context chain searching for context in
@@ -154,6 +157,8 @@ class CyclicReference private (val denot: SymDenotation)(using Context) extends
154
157
case tree : untpd.ValOrDefDef if ! tree.tpt.typeOpt.exists =>
155
158
if (inImplicitSearch)
156
159
TermMemberNeedsResultTypeForImplicitSearch (cycleSym)
160
+ else if (isConstructor)
161
+ CyclicMsgUnknownBug (cycleSym)
157
162
else if (isMethod)
158
163
OverloadedOrRecursiveMethodNeedsResultType (cycleSym)
159
164
else if (isVal)
Original file line number Diff line number Diff line change @@ -1231,6 +1231,14 @@ extends CyclicMsg(OverloadedOrRecursiveMethodNeedsResultTypeID) {
1231
1231
| """
1232
1232
}
1233
1233
1234
+ class CyclicMsgUnknownBug (cycleSym : Symbol )(using Context )
1235
+ extends CyclicMsg (OverloadedOrRecursiveMethodNeedsResultTypeID ) {
1236
+ def msg (using Context ) = i """ Compiler bug: unknown cyclic error for $cycleSym. please report """
1237
+ def explain (using Context ) =
1238
+ i """ |For temporary fix, add type annotations to areas involving this constructor
1239
+ """
1240
+ }
1241
+
1234
1242
class RecursiveValueNeedsResultType (cycleSym : Symbol )(using Context )
1235
1243
extends CyclicMsg (RecursiveValueNeedsResultTypeID ) {
1236
1244
def msg (using Context ) = i """ Recursive $cycleSym needs type """
You can’t perform that action at this time.
0 commit comments