@@ -31,14 +31,6 @@ object FooNested:
31
31
object Nested :
32
32
def hello = Set ()
33
33
34
- object FooGivenUnused :
35
- import SomeGivenImports .given // error
36
-
37
- object FooGiven :
38
- import SomeGivenImports .given // OK
39
- import SomeGivenImports ._ // error
40
-
41
- val foo = summon[Int ]
42
34
43
35
/**
44
36
* Import used as type name are considered
@@ -92,12 +84,6 @@ object IgnoreExclusion:
92
84
def check =
93
85
val a = Set (1 )
94
86
val b = Map (1 -> 2 )
95
- /**
96
- * Some given values for the test
97
- */
98
- object SomeGivenImports :
99
- given Int = 0
100
- given String = " foo"
101
87
102
88
/* BEGIN : Check on packages*/
103
89
package p {
@@ -115,9 +101,10 @@ package p {
115
101
/* END : Check on packages*/
116
102
117
103
/* BEGIN : tests on meta-language features */
118
- object TestGivenCoversionScala2 :
104
+ object TestLanguageImportAreIgnored :
119
105
/* note: scala3 Conversion[U,T] do not require an import */
120
106
import language .implicitConversions // OK
107
+ import language ._ // OK
121
108
122
109
implicit def doubleToInt (d: Double ): Int = d.toInt
123
110
@@ -153,4 +140,43 @@ object GivenImportOrderBtoA:
153
140
import A ._ // error
154
141
def t = implicitly[X ]
155
142
}
156
- /* END : tests on given import order */
143
+ /* END : tests on given import order */
144
+
145
+ /*
146
+ * Advanced tests on given imports meta-programming
147
+ *
148
+ * - Currently also tests that no imported implicits are reported
149
+ */
150
+
151
+ package summoninlineconflict:
152
+ package lib:
153
+ trait A
154
+ trait B
155
+ trait C
156
+ trait X
157
+
158
+ given willBeUnused : (A & X ) = new A with X {}
159
+ given willBeUsed : (A & B ) = new A with B {}
160
+ given notUsedAtAll : Int = 0
161
+
162
+ package use:
163
+ import lib .{A , B , C , willBeUnused , willBeUsed , notUsedAtAll } // OK
164
+ import compiletime .summonInline // OK
165
+
166
+ transparent inline given conflictInside : C =
167
+ summonInline[A ]
168
+ new {}
169
+
170
+ transparent inline given potentialConflict : C =
171
+ summonInline[B ]
172
+ new {}
173
+
174
+ val b : B = summon[B ]
175
+ val c : C = summon[C ]
176
+
177
+ package unusedgivensimports:
178
+ package foo:
179
+ given Int = 0
180
+
181
+ package bar:
182
+ import foo .given // OK
0 commit comments