@@ -31,6 +31,7 @@ import io.AbstractFile
31
31
import util .{SourceFile , NoSource , Property , SourcePosition , SrcPos , EqHashMap }
32
32
import scala .annotation .internal .sharable
33
33
import config .Printers .typr
34
+ import dotty .tools .dotc .classpath .FileUtils .isScalaBinary
34
35
35
36
object Symbols {
36
37
@@ -150,8 +151,7 @@ object Symbols {
150
151
* symbols defined by the user in a prior run of the REPL, that are still valid.
151
152
*/
152
153
final def isDefinedInSource (using Context ): Boolean =
153
- span.exists && isValidInCurrentRun
154
- && associatedFileMatches(file => file.extension != " class" && file.extension != " tasty" )
154
+ span.exists && isValidInCurrentRun && associatedFileMatches(! _.isScalaBinary)
155
155
156
156
/** Is symbol valid in current run? */
157
157
final def isValidInCurrentRun (using Context ): Boolean =
@@ -272,7 +272,7 @@ object Symbols {
272
272
/** The class file from which this class was generated, null if not applicable. */
273
273
final def binaryFile (using Context ): AbstractFile | Null = {
274
274
val file = associatedFile
275
- if file != null && ( file.extension == " class " || file.extension == " tasty " ) then file else null
275
+ if file != null && file.isScalaBinary then file else null
276
276
}
277
277
278
278
/** A trap to avoid calling x.symbol on something that is already a symbol.
@@ -285,7 +285,7 @@ object Symbols {
285
285
286
286
final def source (using Context ): SourceFile = {
287
287
def valid (src : SourceFile ): SourceFile =
288
- if (src.exists && src.file.extension != " class " && src.file.extension != " tasty " ) src
288
+ if (src.exists && ! src.file.isScalaBinary ) src
289
289
else NoSource
290
290
291
291
if (! denot.exists) NoSource
@@ -463,7 +463,7 @@ object Symbols {
463
463
if ! mySource.exists && ! denot.is(Package ) then
464
464
// this allows sources to be added in annotations after `sourceOfClass` is first called
465
465
val file = associatedFile
466
- if file != null && file.extension != " class " && file.extension != " tasty " then
466
+ if file != null && ! file.isScalaBinary then
467
467
mySource = ctx.getSource(file)
468
468
else
469
469
mySource = defn.patchSource(this )
0 commit comments