Skip to content

Commit d74c261

Browse files
authored
Merge pull request #34681 from rxwei/71191415-debug-scope
2 parents 2aac6d2 + c9dc67d commit d74c261

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

lib/AST/Decl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,9 @@ static_assert(sizeof(checkSourceLocType(&ID##Decl::getLoc)) == 2, \
654654
// When the decl is context-free, we should get loc from source buffer.
655655
if (!getDeclContext())
656656
return getLocFromSource();
657-
auto *File = cast<FileUnit>(getDeclContext()->getModuleScopeContext());
657+
FileUnit *File = dyn_cast<FileUnit>(getDeclContext()->getModuleScopeContext());
658+
if (!File)
659+
return getLocFromSource();
658660
switch(File->getKind()) {
659661
case FileUnitKind::Source:
660662
return getLocFromSource();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %target-build-swift -O %s
2+
3+
// rdar://71191415
4+
5+
import _Differentiation
6+
7+
protocol P {
8+
@differentiable
9+
func req(_ input: Float) -> Float
10+
}
11+
12+
extension P {
13+
@differentiable
14+
func foo(_ input: Float) -> Float {
15+
return req(input)
16+
}
17+
}
18+
19+
struct Dummy: P {
20+
@differentiable
21+
func req(_ input: Float) -> Float {
22+
input
23+
}
24+
}
25+
26+
struct DummyComposition: P {
27+
var layer = Dummy()
28+
29+
@differentiable
30+
func req(_ input: Float) -> Float {
31+
layer.foo(input)
32+
}
33+
}

0 commit comments

Comments
 (0)