File tree 4 files changed +23
-9
lines changed
compiler/src/dotty/tools/dotc/typer
4 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,10 @@ object Inferencing {
33
33
*/
34
34
def isFullyDefined (tp : Type , force : ForceDegree .Value )(using Context ): Boolean = {
35
35
val nestedCtx = ctx.fresh.setNewTyperState()
36
- val result = new IsFullyDefinedAccumulator (force)(using nestedCtx).process(tp)
36
+ val result =
37
+ try new IsFullyDefinedAccumulator (force)(using nestedCtx).process(tp)
38
+ catch case ex : StackOverflowError =>
39
+ false // can happen for programs with illegal recusions, e.g. neg/recursive-lower-constraint.scala
37
40
if (result) nestedCtx.typerState.commit()
38
41
result
39
42
}
@@ -43,7 +46,7 @@ object Inferencing {
43
46
*/
44
47
def canDefineFurther (tp : Type )(using Context ): Boolean =
45
48
val prevConstraint = ctx.typerState.constraint
46
- isFullyDefined(tp, force = ForceDegree .all )
49
+ isFullyDefined(tp, force = ForceDegree .failBottom )
47
50
&& (ctx.typerState.constraint ne prevConstraint)
48
51
49
52
/** The fully defined type, where all type variables are forced.
Original file line number Diff line number Diff line change 4
4
|Cannot construct a collection of type List[String] with elements of type Int based on a collection of type List[Int]..
5
5
|I found:
6
6
|
7
- | collection.BuildFrom.buildFromIterableOps[Nothing, Nothing, Nothing ]
7
+ | collection.BuildFrom.buildFromIterableOps[CC, A0, A ]
8
8
|
9
9
|But method buildFromIterableOps in trait BuildFromLowPriority2 does not match type collection.BuildFrom[List[Int], Int, List[String]].
Original file line number Diff line number Diff line change 1
- -- [E008] Not Found Error: tests/neg/i7056.scala:19:10 --- --------------------------------------------------------------
1
+ -- [E007] Type Mismatch Error: tests/neg/i7056.scala:19:8 --------------------------------------------------------------
2
2
19 |val z = x.idnt1 // error
3
- | ^^^^^^^
4
- | value idnt1 is not a member of B.
5
- | An extension method was tried, but could not be fully constructed:
3
+ | ^
4
+ | Found: (given_PartialId_B : B)
5
+ | Required: PartialId[T]
6
6
|
7
- | given_T1_T[T](given_PartialId_B).idnt1()
7
+ | where: T is a type variable with constraint <: A
8
+ |
9
+ |
10
+ | Note: a match type could not be fully reduced:
11
+ |
12
+ | trying to reduce PartialId[T]
13
+ | failed since selector T
14
+ | matches none of the cases
15
+ |
16
+ | case B => T
17
+
18
+ longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change @@ -6,5 +6,5 @@ object C {
6
6
trait X [T ]
7
7
implicit def u [A , B ]: X [A | B ] = new X [A | B ] {}
8
8
def y [T ](implicit x : X [T ]): T = ???
9
- val x : a.type & b.type | b.type & c.type = y
9
+ val x : a.type & b.type | b.type & c.type = y // error
10
10
}
You can’t perform that action at this time.
0 commit comments