Skip to content

Commit 6efc9fa

Browse files
authored
Merge pull request #142 from julia-vscode/pirates
piracy fix
2 parents 6843434 + 1ddf7f0 commit 6efc9fa

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/linting/checks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ end
507507
function refers_to_nonimported_type(arg::EXPR)
508508
if hasref(arg) && refof(arg) isa Binding
509509
return true
510-
elseif typof(arg) === CSTParser.UnaryOpCall && length(arg) == 2 && kindof(arg[1]) === CSTParser.Tokens.DECLARATION
510+
elseif typof(arg) === CSTParser.UnaryOpCall && length(arg) == 2 && (kindof(arg[1]) === CSTParser.Tokens.DECLARATION || kindof(arg[1]) === CSTParser.Tokens.ISSUBTYPE)
511511
return refers_to_nonimported_type(arg[2])
512512
elseif _binary_assert(arg, CSTParser.Tokens.DECLARATION)
513513
return refers_to_nonimported_type(arg[3])

test/runtests.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,23 @@ end
464464
StaticLint.check_for_pirates(cst[2])
465465
@test errorof(cst[2]) === nothing
466466
end
467+
let cst = parse_and_pass("""
468+
import Base:sin
469+
abstract type T end
470+
sin(x::Array{T}) = 1
471+
sin(x::Array{<:T}) = 1
472+
sin(x::Array{Number}) = 1
473+
sin(x::Array{<:Number}) = 1
474+
""")
475+
StaticLint.check_for_pirates(cst[3])
476+
StaticLint.check_for_pirates(cst[4])
477+
StaticLint.check_for_pirates(cst[5])
478+
StaticLint.check_for_pirates(cst[6])
479+
@test errorof(cst[3]) === nothing
480+
@test errorof(cst[4]) === nothing
481+
@test errorof(cst[5]) === StaticLint.TypePiracy
482+
@test errorof(cst[6]) === StaticLint.TypePiracy
483+
end
467484
end
468485

469486
@testset "docs for undescribed variables" begin

0 commit comments

Comments
 (0)