Skip to content

Commit b010fad

Browse files
committed
Take out ambiguous negation
1 parent 408d35b commit b010fad

File tree

12 files changed

+33
-40
lines changed

12 files changed

+33
-40
lines changed

compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
344344
if newSet.isEmpty then deps.remove(referenced)
345345
else deps.updated(referenced, newSet)
346346

347-
def traverse(t: Type) = try
348-
t match
347+
def traverse(t: Type) = t match
349348
case param: TypeParamRef =>
350349
if hasBounds(param) then
351350
if variance >= 0 then coDeps = update(coDeps, param)
@@ -357,7 +356,6 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
357356
seen += tp
358357
traverse(tp.ref)
359358
case _ => traverseChildren(t)
360-
catch case ex: Throwable => handleRecursive("adjust", t.show, ex)
361359
end Adjuster
362360

363361
/** Adjust dependencies to account for the delta of previous entry `prevEntry`

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ trait Applications extends Compatibility {
844844
var typedArgs = typedArgBuf.toList
845845
def app0 = cpy.Apply(app)(normalizedFun, typedArgs) // needs to be a `def` because typedArgs can change later
846846
val app1 =
847-
if (!success || typedArgs.exists(_.tpe.isError)) app0.withType(UnspecifiedErrorType)
847+
if (!success) app0.withType(UnspecifiedErrorType)
848848
else {
849849
if !sameSeq(args, orderedArgs)
850850
&& !isJavaAnnotConstr(methRef.symbol)

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,9 +1328,7 @@ trait Implicits:
13281328
* worse than the successful candidate.
13291329
* If a trial failed:
13301330
* - if the query term is a `Not[T]` treat it as a success,
1331-
* - otherwise, if the failure is an ambiguity, try to heal it (see `healAmbiguous`)
1332-
* and return an ambiguous error otherwise. However, under Scala2 mode this is
1333-
* treated as a simple failure, with a warning that semantics will change.
1331+
* - otherwise, if the failure is an ambiguity, treat it as a simple failure.
13341332
* - otherwise add the failure to `rfailures` and continue testing the other candidates.
13351333
*/
13361334
def rank(pending: List[Candidate], found: SearchResult, rfailures: List[SearchFailure]): SearchResult =
@@ -1348,17 +1346,8 @@ trait Implicits:
13481346
case fail: SearchFailure =>
13491347
if fail eq ImplicitSearchTooLargeFailure then
13501348
fail
1351-
else if (fail.isAmbiguous)
1352-
if migrateTo3 then
1353-
val result = rank(remaining, found, NoMatchingImplicitsFailure :: rfailures)
1354-
if (result.isSuccess)
1355-
warnAmbiguousNegation(fail.reason.asInstanceOf[AmbiguousImplicits])
1356-
result
1357-
else
1358-
// The ambiguity happened in a nested search: to recover we
1359-
// need a candidate better than `cand`
1360-
healAmbiguous(fail, newCand =>
1361-
compareAlternatives(newCand, cand) > 0)
1349+
else if fail.isAmbiguous then
1350+
rank(remaining, found, NoMatchingImplicitsFailure :: rfailures)
13621351
else rank(remaining, found, fail :: rfailures)
13631352
case best: SearchSuccess =>
13641353
if (ctx.mode.is(Mode.ImplicitExploration) || isCoherent)

language-server/test/dotty/tools/languageserver/SignatureHelpTest.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -929,12 +929,12 @@ class SignatureHelpTest {
929929
| def boo(x: Int, y: Int): Int = ???
930930
| boo(${m1}, fo${m2}o1(fo${m3}o2(fo${m4}o3(fo${m5}o4(fo${m6}o5(${m7}))))))"""
931931
.signatureHelp(m1, List(booSignature), None, 0)
932-
.signatureHelp(m2, List(booSignature), None, 0)
933-
.signatureHelp(m3, List(booSignature), None, 0)
934-
.signatureHelp(m4, List(booSignature), None, 0)
935-
.signatureHelp(m5, List(booSignature), None, 0)
936-
.signatureHelp(m6, List(booSignature), None, 0)
937-
.signatureHelp(m7, List(booSignature), None, 0)
932+
.signatureHelp(m2, List(booSignature), None, 1)
933+
.signatureHelp(m3, List(signatures(0)), None, 0)
934+
.signatureHelp(m4, List(signatures(1)), None, 0)
935+
.signatureHelp(m5, List(signatures(2)), None, 0)
936+
.signatureHelp(m6, List(signatures(3)), None, 0)
937+
.signatureHelp(m7, List(signatures(4)), None, 0)
938938
}
939939

940940
@Test def multipleNestedApplySignatures: Unit = {
@@ -956,12 +956,12 @@ class SignatureHelpTest {
956956
.signatureHelp(m1, List(simpleSignature), None, 0)
957957
.signatureHelp(m2, List(complicatedSignature), None, 0)
958958
.signatureHelp(m3, List(simpleSignature), None, 0)
959-
.signatureHelp(m4, List(complicatedSignature), None, 0)
960-
.signatureHelp(m5, List(complicatedSignature), None, 0)
961-
.signatureHelp(m6, List(complicatedSignature), None, 0)
962-
.signatureHelp(m7, List(complicatedSignature), None, 0)
963-
.signatureHelp(m8, List(complicatedSignature), None, 0)
964-
.signatureHelp(m9, List(complicatedSignature), None, 0)
959+
.signatureHelp(m4, List(complicatedSignature), None, 1)
960+
.signatureHelp(m5, List(complicatedSignature), None, 1)
961+
.signatureHelp(m6, List(complicatedSignature), None, 2)
962+
.signatureHelp(m7, List(simpleSignature), None, 0)
963+
.signatureHelp(m8, List(complicatedSignature), None, 2)
964+
.signatureHelp(m9, List(complicatedSignature), None, 1)
965965
}
966966

967967
@Test def noHelpSignatureWithPositionedOnName: Unit = {

presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTypeSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class HoverTypeSuite extends BaseHoverSuite:
142142
| "".<<doub@@le(1)>>
143143
|end Foo
144144
|""".stripMargin,
145-
""
145+
"extension [T](using A)(s: T) def double(using B)[G](using C)(times: G): String".hover
146146
)
147147

148148
@Test def `extension-methods-complex-binary` =

tests/neg-macros/i6762.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ import scala.quoted.*
22

33
type G[X]
44
case class Foo[T](x: T)
5-
def f(word: String)(using Quotes): Expr[Foo[G[String]]] = '{Foo(${Expr(word)})} // error
5+
def f(word: String)(using Quotes): Expr[Foo[G[String]]] = '{Foo(${Expr(word)})} // error // error

tests/neg/enum-values.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
|
2525
| failed with:
2626
|
27-
| Found: example.ListLike.type
28-
| Required: Nothing
27+
| Found: Array[example.Tag[?]]
28+
| Required: Array[example.ListLike[?]]
2929
-- [E008] Not Found Error: tests/neg/enum-values.scala:34:52 -----------------------------------------------------------
3030
34 | val typeCtorsK: Array[TypeCtorsK[?]] = TypeCtorsK.values // error
3131
| ^^^^^^^^^^^^^^^^^
@@ -38,8 +38,8 @@
3838
|
3939
| failed with:
4040
|
41-
| Found: example.TypeCtorsK.type
42-
| Required: Nothing
41+
| Found: Array[example.Tag[?]]
42+
| Required: Array[example.TypeCtorsK[?[_$1]]]
4343
-- [E008] Not Found Error: tests/neg/enum-values.scala:36:6 ------------------------------------------------------------
4444
36 | Tag.valueOf("Int") // error
4545
| ^^^^^^^^^^^

tests/neg/enumsAccess.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ object test5 {
6363
enum E5[T](x: T) {
6464
case C3() extends E5[INT](defaultX)// error: illegal reference // error: illegal reference
6565
case C4 extends E5[INT](defaultX) // error: illegal reference // error: illegal reference
66-
case C5 extends E5[E5[_]](E5.this) // error: cannot be instantiated // error: conflicting base types // error: type mismatch
66+
case C5 extends E5[E5[_]](E5.this) // error: type mismatch
6767
}
6868

6969
object E5 {

tests/neg/i6779.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
| value f is not a member of T.
1212
| An extension method was tried, but could not be fully constructed:
1313
|
14-
| Test.f[G[T]](x)
14+
| Test.f[G[T]](x)(given_Stuff)
1515
|
1616
| failed with:
1717
|

tests/neg/recursive-lower-constraint.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ class Bar extends Foo[Bar]
33

44
class A {
55
def foo[T <: Foo[T], U >: Foo[T] <: T](x: T): T = x
6-
foo(new Bar) // error // error
6+
foo(new Bar) // error
77
}

tests/neg/syntax-error-recovery.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@
9494
| Not found: bam
9595
|
9696
| longer explanation available when compiling with `-explain`
97+
-- [E006] Not Found Error: tests/neg/syntax-error-recovery.scala:61:10 -------------------------------------------------
98+
61 | println(bam) // error
99+
| ^^^
100+
| Not found: bam
101+
|
102+
| longer explanation available when compiling with `-explain`
97103
-- [E129] Potential Issue Warning: tests/neg/syntax-error-recovery.scala:7:2 -------------------------------------------
98104
6 | 2
99105
7 | }

tests/neg/syntax-error-recovery.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ object Test2:
5858
def foo5(x: Int) =
5959
foo2(foo2(,) // error // error
6060

61-
println(bam)
61+
println(bam) // error
6262
// error

0 commit comments

Comments
 (0)