(tp *typeparser.TypeParser, c *checker.Checker, sf *ast.SourceFile, node *ast.Node, errorSymbol *ast.Symbol)
| 65 | } |
| 66 | |
| 67 | func checkExtendsNativeError(tp *typeparser.TypeParser, c *checker.Checker, sf *ast.SourceFile, node *ast.Node, errorSymbol *ast.Symbol) *ExtendsNativeErrorMatch { |
| 68 | extendsElements := ast.GetExtendsHeritageClauseElements(node) |
| 69 | if len(extendsElements) == 0 { |
| 70 | return nil |
| 71 | } |
| 72 | |
| 73 | for _, elem := range extendsElements { |
| 74 | if elem.Kind != ast.KindExpressionWithTypeArguments { |
| 75 | continue |
| 76 | } |
| 77 | expr := elem.AsExpressionWithTypeArguments().Expression |
| 78 | |
| 79 | exprSymbol := tp.GetSymbolAtLocation(expr) |
| 80 | resolvedSymbol := exprSymbol |
| 81 | if resolvedSymbol != nil && resolvedSymbol.Flags&ast.SymbolFlagsAlias != 0 { |
| 82 | resolvedSymbol = c.GetAliasedSymbol(resolvedSymbol) |
| 83 | } |
| 84 | |
| 85 | isNativeError := resolvedSymbol == errorSymbol |
| 86 | if !isNativeError && resolvedSymbol != nil && resolvedSymbol != errorSymbol { |
| 87 | exprType := tp.GetTypeAtLocation(expr) |
| 88 | if exprType != nil { |
| 89 | constructSignatures := c.GetSignaturesOfType(exprType, checker.SignatureKindConstruct) |
| 90 | if len(constructSignatures) > 0 { |
| 91 | instanceType := c.GetReturnTypeOfSignature(constructSignatures[0]) |
| 92 | if instanceType != nil && instanceType.Symbol() == errorSymbol { |
| 93 | isNativeError = true |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | if isNativeError { |
| 100 | locationNode := node.Name() |
| 101 | if locationNode == nil { |
| 102 | locationNode = expr |
| 103 | } |
| 104 | return &ExtendsNativeErrorMatch{ |
| 105 | SourceFile: sf, |
| 106 | Location: scanner.GetErrorRangeForNode(sf, locationNode), |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | return nil |
| 112 | } |
no test coverage detected