Files
swift-mirror/test/SourceKit/Misc/no-crash-reopen-with-different-compiler-args.swift
Alex Hoppen f5b6103ef7 [SourceKit] Fix a crash that occurred when a document without an associated source file is reopened
When opening a file for the first time, we don’t store a snapshot for it. This could cause a crash when trying to consult its snapshot to see whether an AST can be reused for cursor info.
2021-12-13 16:43:32 +01:00

23 lines
836 B
Swift

// RUN: %empty-directory(%t)
// RUN: %{python} %utils/split_file.py -o %t %s
// This used to crash with a nullptr dereference because we didn't store a
// snapshot in the FileContents of primary.swift when it is opened for the first
// time but we are trying to access the snapshot when trying determining if we
// can reuse the AST for the cursor info request
// RUN: %sourcekitd-test \
// RUN: -req=open %t/primary.swift -- %t/primary.swift %t/secondary.swift \
// RUN: == -req=close %t/primary.swift \
// RUN: == -req=open %t/primary.swift -- %t/primary.swift \
// RUN: == -req=cursor -pos 2:8 %t/primary.swift -- %t/primary.swift %t/secondary.swift \
// RUN: | %FileCheck %s
// BEGIN primary.swift
struct Foo {}
// CHECK: source.lang.swift.decl.struct
// CHECK-NEXT: Foo
// CHECK-NEXT: s:4main3FooV
// BEGIN secondary.swift