@@ -1294,4 +1294,83 @@ class ErrorMessagesTests extends ErrorMessagesTest {
1294
1294
val JavaSymbolIsNotAValue (symbol) = messages.head
1295
1295
assertEquals(symbol.show, " package p" )
1296
1296
}
1297
+
1298
+ @ Test def userDefinedImplicitAmbiguous1 =
1299
+ checkMessagesAfter(" frontend" ) {
1300
+ """
1301
+ |object Test {
1302
+ | trait =!=[C, D]
1303
+ |
1304
+ | implicit def neq[E, F] : E =!= F = null
1305
+ |
1306
+ | @annotation.implicitAmbiguous("Could not prove ${J} =!= ${J}")
1307
+ | implicit def neqAmbig1[G, H, J] : J =!= J = null
1308
+ | implicit def neqAmbig2[I] : I =!= I = null
1309
+ |
1310
+ | implicitly[Int =!= Int]
1311
+ }
1312
+
1313
+ """ .stripMargin
1314
+ }.expect { (itcx, messages) =>
1315
+ import diagnostic .NoExplanation
1316
+ implicit val ctx : Context = itcx
1317
+
1318
+ assertMessageCount(1 , messages)
1319
+ val (m : NoExplanation ) :: Nil = messages
1320
+
1321
+ assertEquals(m.msg, " Could not prove Int =!= Int" )
1322
+ }
1323
+
1324
+ @ Test def userDefinedImplicitAmbiguous2 =
1325
+ checkMessagesAfter(" frontend" ) {
1326
+ """
1327
+ |object Test {
1328
+ | trait =!=[C, D]
1329
+ |
1330
+ | implicit def neq[E, F] : E =!= F = null
1331
+ |
1332
+ | implicit def neqAmbig1[G, H, J] : J =!= J = null
1333
+ | @annotation.implicitAmbiguous("Could not prove ${I} =!= ${I}")
1334
+ | implicit def neqAmbig2[I] : I =!= I = null
1335
+ |
1336
+ | implicitly[Int =!= Int]
1337
+ }
1338
+
1339
+ """ .stripMargin
1340
+ }.expect { (itcx, messages) =>
1341
+ import diagnostic .NoExplanation
1342
+ implicit val ctx : Context = itcx
1343
+
1344
+ assertMessageCount(1 , messages)
1345
+ val (m : NoExplanation ) :: Nil = messages
1346
+
1347
+ assertEquals(m.msg, " Could not prove Int =!= Int" )
1348
+ }
1349
+
1350
+ @ Test def userDefinedImplicitAmbiguous3 =
1351
+ checkMessagesAfter(" frontend" ) {
1352
+ """
1353
+ |object Test {
1354
+ | trait =!=[C, D]
1355
+ |
1356
+ | implicit def neq[E, F] : E =!= F = null
1357
+ |
1358
+ | @annotation.implicitAmbiguous("Could not prove ${J} =!= ${J}")
1359
+ | implicit def neqAmbig1[G, H, J] : J =!= J = null
1360
+ | @annotation.implicitAmbiguous("Could not prove ${I} =!= ${I}")
1361
+ | implicit def neqAmbig2[I] : I =!= I = null
1362
+ |
1363
+ | implicitly[Int =!= Int]
1364
+ }
1365
+
1366
+ """ .stripMargin
1367
+ }.expect { (itcx, messages) =>
1368
+ import diagnostic .NoExplanation
1369
+ implicit val ctx : Context = itcx
1370
+
1371
+ assertMessageCount(1 , messages)
1372
+ val (m : NoExplanation ) :: Nil = messages
1373
+
1374
+ assertEquals(m.msg, " Could not prove Int =!= Int" )
1375
+ }
1297
1376
}
0 commit comments